<!-- 个人中心 -->
<template>
	<nt-container>
		<view class="user-center">
			<view class="user-center-tabs">
				<view class="tab">配件业绩 <text class="number">{{CountData.count1}} </text> </view>
				<view class="tab">配件单量<text class="number">{{CountData.count2}}</text></view>
			</view>
			<u-cell-group :customStyle="{background:'#fff'}">
				<u-cell v-for="(item,index) in menuList" isLink :title="item.title" :url="item.url"
					:key="index"></u-cell>
			</u-cell-group>
		</view>
	</nt-container>
</template>

<script>
	import {
		getGoodsorderCount
	} from '@/api'
	export default {
		onLoad() {
			const that = this
			uni.$on('userCenterCount', () => {
				that.getCount()
			})
			that.getCount()
		},
		onUnload() {
			uni.$off('userCenterCount')
		},
		data() {
			return {
				CountData: {
					count1: 0,
					count2: 0
				},
				menuList: [{
						title: '商品订单',
						url: '/subpackage/shop/pages/shop/order?dataType=sell'
					},
					{
						title: '我的订单',
						url: '/subpackage/shop/pages/shop/order?dataType=buy'
					},
				]
			}
		},
		methods: {
			async getCount() {
				const {
					data
				} = await getGoodsorderCount()
				this.CountData = data
			},
		}
	}
</script>

<style lang="scss" scoped>
	.user-center {
		&-tabs {
			display: flex;
			align-items: center;
			height: 80rpx;
			font-size: 28rpx;
			color: $uni-color-primary;

			.tab {
				width: 50%;
				text-align: center;

				.number {
					color: #f00;
					padding-left: 20rpx;
				}
			}
		}
	}
</style>